package cn.gjculture.shopping.api.entity;

import cn.gjculture.shopping.api.util.DateUtil;
import org.springframework.util.StringUtils;

import java.text.ParseException;

public class OrderParams extends Order {
    private String startPayTimeStr;
    private String endPayTimeStr;

    private Long startPayTime;
    private Long endPayTime;

    OrderParams(){
        this.setStatus(null);
    }

    public void setOrderNoStr(String orderNoStr){
        if(!StringUtils.isEmpty(orderNoStr)){
            super.setOrderNoStr(orderNoStr);
            super.setOrderNo(Long.parseLong(orderNoStr.substring(2)));
        }
    }

    public String getStartPayTimeStr() {
        return startPayTimeStr;
    }

    public void setStartPayTimeStr(String startPayTimeStr) {
        if(!StringUtils.isEmpty(startPayTimeStr)){
            try {
                this.setStartPayTime(DateUtil.getTimestamp(startPayTimeStr));
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        this.startPayTimeStr = startPayTimeStr;
    }

    public String getEndPayTimeStr() {
        return endPayTimeStr;
    }

    public void setEndPayTimeStr(String endPayTimeStr) {
        this.endPayTimeStr = endPayTimeStr;
        if(!StringUtils.isEmpty(endPayTimeStr)){
            try {
                this.setEndPayTime(DateUtil.getTimestamp(endPayTimeStr));
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
    }

    public Long getStartPayTime() {
        return startPayTime;
    }

    public void setStartPayTime(Long startPayTime) {
        this.startPayTime = startPayTime;
    }

    public Long getEndPayTime() {
        return endPayTime;
    }

    public void setEndPayTime(Long endPayTime) {
        this.endPayTime = endPayTime;
    }
}
